CAN Gateway code example  v1.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
cangw.cpp
Go to the documentation of this file.
1 /***********************************************************************************************//**
2  * @file cangw.cpp
3  * @brief Handling functions for CAN Gateway
4  * @date 2014-03-07
5  * @copyright Hatteland Display AS
6  **************************************************************************************************/
7 
8 //==================================================================================================
9 // Includes
10 //==================================================================================================
11 #include <cstring>
12 #include <pthread.h>
13 #include <unistd.h>
14 #include <new>
15 #include <hdj2534.h>
16 #include "cangw.hpp"
17 
18 //==================================================================================================
19 // Namespaces
20 //==================================================================================================
21 using namespace canGw;
22 
23 //==================================================================================================
24 // Defines
25 //==================================================================================================
26 
27 
28 //==================================================================================================
29 // Typedefs
30 //==================================================================================================
31 /// Definition of structure with CAN Gateway's parameters
32 struct GwParam_s
33 {
34  /// ID of the device
35  unsigned long idDevice;
36  /// ID of the CAN CH1
37  unsigned long idCh1;
38  /// ID of the CAN CH2
39  unsigned long idCh2;
40  /// ID of the filter for CAN CH1
41  unsigned long idFilterCh1;
42  /// ID of the filter for CAN CH2
43  unsigned long idFilterCh2;
44  /// Baud rate of CAN CH1
45  unsigned long baudCh1;
46  /// Baud rate of CAN CH2
47  unsigned long baudCh2;
48  /// CAN CH1 active status
49  bool activeCh1;
50  /// CAN CH2 active status
51  bool activeCh2;
52 };
53 
54 /// Definition of structure with thread parameters
56 {
57  /// Thread's ID
58  pthread_t id;
59  /// Thread's attributes
60  pthread_attr_t attr;
61  /// Thread's status
62  bool active;
63  /// CAN Gateway's channel handled by thread
65 };
66 
67 //==================================================================================================
68 // Declarations of local functions
69 //==================================================================================================
70 static ErrCode_e canGwOpen();
71 static ErrCode_e canGwClose();
74 static ErrCode_e canGwSetFilters();
75 static ErrCode_e canGwInitRcvThread(Channel_e channel);
77 static void * canGwRcvThreadFunc(void * params);
78 
79 //==================================================================================================
80 // Variables
81 //==================================================================================================
82 /// Structure with CAN device parameters
83 static GwParam_s gwParam = {0, 0, 0, 0, 0, 0, 0, false, false};
84 /// Structure with thread parameters for Channel1
86 /// Structure with thread parameters for Channel2
88 /// Mutex for CAN Gateway's API
89 static pthread_mutex_t gwMutex = PTHREAD_MUTEX_INITIALIZER;
90 /// Receive callback function for Channel 1
92 /// Receive callback function for Channel 2
94 /// Pointer to receive buffer with PASSTHRU messages for Channel 1
95 static J2534::PASSTHRU_MSG * rxPassThruMsgCh1 = NULL;
96 /// Pointer to receive buffer with PASSTHRU messages for Channel 2
97 static J2534::PASSTHRU_MSG * rxPassThruMsgCh2 = NULL;
98 
99 /// Maximum number of messages to receive
100 static const unsigned int MAX_RX_MSGS = 20;
101 /// Timeout for PassThruWriteMsgs() function
102 static unsigned long TX_TIMEOUT = 100;
103 /// Value for baud rate = 125 kbps
104 static const unsigned long BAUD_VAL_125KBPS = 125000;
105 /// Value for baud rate = 250 kbps
106 static const unsigned long BAUD_VAL_250KBPS = 250000;
107 /// Value for baud rate = 500 kbps
108 static const unsigned long BAUD_VAL_500KBPS = 500000;
109 /// Value for baud rate = 1 Mbps
110 static const unsigned long BAUD_VAL_1MBPS = 1000000;
111 
112 //==================================================================================================
113 //==================================================================================================
114 
115 /***********************************************************************************************//**
116  * @brief Function initializes CAN Gateway device
117  * @param[in] baudChan1 Baud rate for physical channel 1
118  * @param[in] baudChan2 Baud rate for physical channel 2
119  * @param[in] cbChan1 Callback function for receive on physical channel 1
120  * @param[in] cbChan2 Callback function for receive on physical channel 2
121  * @return CAN_GW_OK No error
122  * @return CAN_GW_ERR An error occurred
123  **************************************************************************************************/
124 ErrCode_e canGw::init(Baudrate_e baudChan1, Baudrate_e baudChan2, const RcvCb_t cbChan1,
125  const RcvCb_t cbChan2)
126 {
127  ErrCode_e err = CAN_GW_OK;
128 
129  if ((NULL != cbChan1) && (NULL != cbChan2))
130  {
131  rcvCbCh1 = cbChan1;
132  rcvCbCh2 = cbChan2;
133  switch (baudChan1)
134  {
135  case BAUD_125K:
136  default:
138  break;
139  case BAUD_250K:
141  break;
142  case BAUD_500K:
144  break;
145  case BAUD_1M:
147  break;
148  }
149  switch (baudChan2)
150  {
151  case BAUD_125K:
152  default:
154  break;
155  case BAUD_250K:
157  break;
158  case BAUD_500K:
160  break;
161  case BAUD_1M:
163  break;
164  }
165  if (NULL == rxPassThruMsgCh1)
166  {
167  rxPassThruMsgCh1 = new (std::nothrow) J2534::PASSTHRU_MSG [MAX_RX_MSGS];
168  if (NULL == rxPassThruMsgCh1)
169  {
170  err = CAN_GW_ERR;
171  }
172  }
173  if (NULL == rxPassThruMsgCh2)
174  {
175  rxPassThruMsgCh2 = new (std::nothrow) J2534::PASSTHRU_MSG [MAX_RX_MSGS];
176  if (NULL == rxPassThruMsgCh2)
177  {
178  err = CAN_GW_ERR;
179  }
180  }
181  if (CAN_GW_OK == err)
182  {
183  err = canGwOpen();
184  if (CAN_GW_OK == err)
185  {
187  if (CAN_GW_OK == err)
188  {
190  }
191  }
192  }
193  }
194  return err;
195 }
196 /***********************************************************************************************//**
197  * @brief Function uninitializes CAN Gateway device
198  * @return CAN_GW_OK No error
199  * @return CAN_GW_ERR An error occurred
200  **************************************************************************************************/
202 {
204  if (CAN_GW_OK == err)
205  {
207  if (CAN_GW_OK == err)
208  {
209  err = canGwClose();
210  if (CAN_GW_OK == err)
211  {
212  delete [] rxPassThruMsgCh1;
213  rxPassThruMsgCh1 = NULL;
214  delete [] rxPassThruMsgCh2;
215  rxPassThruMsgCh2 = NULL;
216  }
217  }
218  }
219  return err;
220 }
221 /***********************************************************************************************//**
222  * @brief Function sends PASSTHRU frame via given channel
223  * @param[in] channel Physical channel to be used for sending of a message
224  * @param[in] txPassThruMsg Pointer to a message to be sent
225  * @return CAN_GW_OK No error
226  * @return CAN_GW_ERR An error occurred
227  **************************************************************************************************/
228 ErrCode_e canGw::send(Channel_e channel, J2534::PASSTHRU_MSG * txPassThruMsg)
229 {
230  using namespace J2534;
231  unsigned long msgNum = 1;
232  unsigned long idCh;
233  ErrCode_e err = CAN_GW_ERR;
234  J2534_ERROR_CODE passThruErr = STATUS_NOERROR;
235 
236  switch (channel)
237  {
238  case CHANNEL_1:
239  default:
240  idCh = gwParam.idCh1;
241  break;
242  case CHANNEL_2:
243  idCh = gwParam.idCh2;
244  break;
245  }
246  pthread_mutex_lock(&gwMutex);
247  passThruErr = PassThruWriteMsgs(idCh, txPassThruMsg, &msgNum, TX_TIMEOUT);
248  pthread_mutex_unlock(&gwMutex);
249  if (STATUS_NOERROR == passThruErr)
250  {
251  err = CAN_GW_OK;
252  }
253  return err;
254 }
255 /***********************************************************************************************//**
256  * @brief Function starts CAN Gateway's periodic message
257  * @param[in] channel Physical channel to be used for sending of a periodic message
258  * @param[in] txPassThruMsg Pointer to a message to be sent periodically
259  * @param[in] interval Interval for a periodic message in miliseconds
260  * @return CAN_GW_OK No error
261  * @return CAN_GW_ERR An error occurred
262  **************************************************************************************************/
263 ErrCode_e canGw::startPeriodic(Channel_e channel, J2534::PASSTHRU_MSG * txPassThruMsg,
264  unsigned long interval)
265 {
266  using namespace J2534;
267  // Note that below idMsg handle is an automatic variable allocated on stack so in this
268  // implementation periodic message will not be terminated with PassThruStopPeriodicMsg()
269  // because idMsg will be forgotten. Started periodic messages will be disabled at channel
270  // disconnection automatically by CAN Gateway.
271  unsigned long idMsg;
272  unsigned long idCh;
273  ErrCode_e err = CAN_GW_ERR;
274  J2534_ERROR_CODE passThruErr = STATUS_NOERROR;
275 
276  switch (channel)
277  {
278  case CHANNEL_1:
279  default:
280  idCh = gwParam.idCh1;
281  break;
282  case CHANNEL_2:
283  idCh = gwParam.idCh2;
284  break;
285  }
286  pthread_mutex_lock(&gwMutex);
287  passThruErr = PassThruStartPeriodicMsg(idCh, txPassThruMsg, &idMsg, interval);
288  pthread_mutex_unlock(&gwMutex);
289  if (STATUS_NOERROR == passThruErr)
290  {
291  err = CAN_GW_OK;
292  }
293  return err;
294 }
295 
296 //==================================================================================================
297 //==================================================================================================
298 
299 /***********************************************************************************************//**
300  * @brief Function opens CAN Gateway
301  * @return CAN_GW_OK No error
302  * @return CAN_GW_ERR An error occurred
303  **************************************************************************************************/
305 {
306  using namespace J2534;
307  ErrCode_e err = CAN_GW_ERR;
308 
309  J2534_ERROR_CODE passThruErr = PassThruOpen(NULL, &gwParam.idDevice);
310  if ( STATUS_NOERROR == passThruErr)
311  {
312  err = canGwConnectChannels();
313  if (CAN_GW_OK == err)
314  {
315  err = canGwSetFilters();
316  }
317  }
318  return err;
319 }
320 /***********************************************************************************************//**
321  * @brief Function closes CAN Gateway
322  * @return CAN_GW_OK No error
323  * @return CAN_GW_ERR An error occurred
324  **************************************************************************************************/
326 {
327  using namespace J2534;
328 
330  if (CAN_GW_OK == err)
331  {
332  J2534_ERROR_CODE passThruErr = PassThruClose(gwParam.idDevice);
333  if (STATUS_NOERROR != passThruErr)
334  {
335  err = CAN_GW_ERR;
336  }
337  }
338  return err;
339 }
340 /***********************************************************************************************//**
341  * @brief Function connects CAN Gateway's channels
342  * @return CAN_GW_OK No error
343  * @return CAN_GW_ERR An error occurred
344  **************************************************************************************************/
346 {
347  using namespace J2534;
348  ErrCode_e err = CAN_GW_OK;
349 
350  if (false == gwParam.activeCh1)
351  {
352  static const unsigned long flagsCh1 = 0;
353  J2534_ERROR_CODE passThruErr = PassThruConnect(gwParam.idDevice, CAN, flagsCh1,
355  if (STATUS_NOERROR == passThruErr)
356  {
357  gwParam.activeCh1 = true;
358  }
359  else
360  {
361  err = CAN_GW_ERR;
362  }
363  }
364  if (CAN_GW_OK == err)
365  {
366  if (false == gwParam.activeCh2)
367  {
368  static const unsigned long flagsCh2 = PHYSICAL_CHANNEL;
369  J2534_ERROR_CODE passThruErr = PassThruConnect(gwParam.idDevice, CAN, flagsCh2,
371  if (STATUS_NOERROR == passThruErr)
372  {
373  gwParam.activeCh2 = true;
374  }
375  else
376  {
377  err = CAN_GW_ERR;
378  }
379  }
380  }
381 
382  return err;
383 }
384 /***********************************************************************************************//**
385  * @brief Function disconnects CAN Gateway's channels
386  * @return CAN_GW_OK No error
387  * @return CAN_GW_ERR An error occurred
388  **************************************************************************************************/
390 {
391  using namespace J2534;
392  ErrCode_e err = CAN_GW_OK;
393 
394  if (false != gwParam.activeCh1)
395  {
396  J2534_ERROR_CODE passThruErr = PassThruDisconnect(gwParam.idCh1);
397  if (STATUS_NOERROR == passThruErr)
398  {
399  gwParam.activeCh1 = false;
400  }
401  else
402  {
403  err = CAN_GW_ERR;
404  }
405  }
406  if (CAN_GW_OK == err)
407  {
408  if (false != gwParam.activeCh2)
409  {
410  J2534_ERROR_CODE passThruErr = PassThruDisconnect(gwParam.idCh2);
411  if (STATUS_NOERROR == passThruErr)
412  {
413  gwParam.activeCh2 = false;
414  }
415  else
416  {
417  err = CAN_GW_ERR;
418  }
419  }
420  }
421  return err;
422 }
423 /***********************************************************************************************//**
424  * @brief Function sets CAN Gateway's message filters
425  * @return CAN_GW_OK No error
426  * @return CAN_GW_ERR An error occurred
427  **************************************************************************************************/
429 {
430  using namespace J2534;
431  ErrCode_e err = CAN_GW_OK;
432 
433  J2534_ERROR_CODE passThruErr = PassThruIoctl(gwParam.idCh1, CLEAR_MSG_FILTERS, NULL, NULL);
434  if (STATUS_NOERROR != passThruErr)
435  {
436  err = CAN_GW_ERR;
437  }
438  passThruErr = PassThruIoctl(gwParam.idCh2, CLEAR_MSG_FILTERS, NULL, NULL);
439  if (STATUS_NOERROR != passThruErr)
440  {
441  err = CAN_GW_ERR;
442  }
443  if (CAN_GW_OK == err)
444  {
445  PASSTHRU_MSG maskPassThruMsg;
446  PASSTHRU_MSG patternPassThruMsg;
447  J2534_ConnectFlags filterFlags;
448 
449  memset(&maskPassThruMsg, 0, sizeof(PASSTHRU_MSG));
450  maskPassThruMsg.ProtocolID = CAN;
451  filterFlags.bits.Can29BitId = 0;
452  maskPassThruMsg.TxFlags = filterFlags.value;
453  memset(&patternPassThruMsg, 0, sizeof(PASSTHRU_MSG));
454  patternPassThruMsg.ProtocolID = CAN;
455  filterFlags.bits.Can29BitId = 0;
456  patternPassThruMsg.TxFlags = filterFlags.value;
457 
458  passThruErr = PassThruStartMsgFilter(gwParam.idCh1, PASS_FILTER, &maskPassThruMsg,
459  &patternPassThruMsg, NULL, &gwParam.idFilterCh1);
460  if (STATUS_NOERROR != passThruErr)
461  {
462  err = CAN_GW_ERR;
463  }
464  passThruErr = PassThruStartMsgFilter(gwParam.idCh2, PASS_FILTER, &maskPassThruMsg,
465  &patternPassThruMsg, NULL, &gwParam.idFilterCh2);
466  if (STATUS_NOERROR != passThruErr)
467  {
468  err = CAN_GW_ERR;
469  }
470  }
471  return err;
472 }
473 /***********************************************************************************************//**
474  * @brief Function initializes receiving thread for given physical channel
475  * @param[in] channel CAN Gateway's physical channel
476  * @return CAN_GW_OK No error
477  * @return CAN_GW_ERR An error occurred
478  **************************************************************************************************/
480 {
481  ErrCode_e err = CAN_GW_OK;
482  ThreadParam_s * threadParam;
483 
484  switch (channel)
485  {
486  case CHANNEL_1:
487  default:
488  threadParam = &threadParamCh1;
489  break;
490  case CHANNEL_2:
491  threadParam = &threadParamCh2;
492  break;
493  }
494  threadParam->gwChannel = channel;
495  threadParam->active = true;
496  threadParam->id = 0;
497  int retVal = pthread_attr_init(&threadParam->attr);
498  if ( 0 == retVal )
499  {
500  retVal = pthread_attr_setdetachstate(&threadParam->attr, PTHREAD_CREATE_JOINABLE);
501  if ( 0 == retVal )
502  {
503  retVal = pthread_create(&threadParam->id, &threadParamCh1.attr, &canGwRcvThreadFunc,
504  threadParam);
505  if ( 0 == retVal )
506  {
507  pthread_attr_destroy(&threadParam->attr);
508  }
509  else
510  {
511  err = CAN_GW_ERR;
512  threadParam->active = false;
513  }
514  }
515  else
516  {
517  threadParam->active = false;
518  err = CAN_GW_ERR;
519  }
520  }
521  else
522  {
523  err = CAN_GW_ERR;
524  }
525  return err;
526 }
527 /***********************************************************************************************//**
528  * @brief Function uninitializes receiving thread for given physical channel
529  * @param[in] channel CAN Gateway's physical channel
530  * @return CAN_GW_OK No error
531  * @return CAN_GW_ERR An error occurred
532  **************************************************************************************************/
534 {
535  ErrCode_e err = CAN_GW_OK;
536  ThreadParam_s * threadParam;
537 
538  switch (channel)
539  {
540  case CHANNEL_1:
541  default:
542  threadParam = &threadParamCh1;
543  break;
544  case CHANNEL_2:
545  threadParam = &threadParamCh2;
546  break;
547  }
548  if (false != threadParam->active)
549  {
550  int retVal = pthread_cancel(threadParam->id);
551  if (0 == retVal)
552  {
553  pthread_join(threadParam->id, NULL);
554  threadParam->active = false;
555  }
556  else
557  {
558  err = CAN_GW_ERR;
559  }
560  }
561  return err;
562 }
563 /***********************************************************************************************//**
564  * @brief Function handles CAN Gateway's receiving threads
565  * @param[in] params Pointer to structure {@link ThreadParam_s} with thread parameters
566  * @return Pointer to status of the thread - always NULL
567  **************************************************************************************************/
568 static void * canGwRcvThreadFunc(void * params)
569 {
570  using namespace J2534;
571  ThreadParam_s * threadParam = reinterpret_cast<ThreadParam_s *>(params);
572  unsigned long msgNum;
573  // In this example timeout is not used
574  static unsigned long RX_TIMEOUT = 0;
575  // 25 ms delay for thread loops
576  static const unsigned int THREAD_DELAY = 25 * 1000;
577 
578  if (CHANNEL_1 == threadParam->gwChannel)
579  {
580  while (1)
581  {
582  msgNum = MAX_RX_MSGS;
583  pthread_mutex_lock(&gwMutex);
584  J2534_ERROR_CODE passThruErr = PassThruReadMsgs(gwParam.idCh1, rxPassThruMsgCh1,
585  &msgNum, RX_TIMEOUT);
586  pthread_mutex_unlock(&gwMutex);
587  if (STATUS_NOERROR == passThruErr)
588  {
589  rcvCbCh1(rxPassThruMsgCh1, msgNum);
590  }
591  else if (ERR_BUFFER_EMPTY == passThruErr)
592  {
593  ; // User defined action
594  }
595  else
596  {
597  ; // User defined error handling
598  }
599  usleep(THREAD_DELAY);
600  }
601  }
602  else if (CHANNEL_2 == threadParam->gwChannel)
603  {
604  while (1)
605  {
606  msgNum = MAX_RX_MSGS;
607  pthread_mutex_lock(&gwMutex);
608  J2534_ERROR_CODE passThruErr = PassThruReadMsgs(gwParam.idCh2, rxPassThruMsgCh2,
609  &msgNum, RX_TIMEOUT);
610  pthread_mutex_unlock(&gwMutex);
611  if (STATUS_NOERROR == passThruErr)
612  {
613  rcvCbCh2(rxPassThruMsgCh2, msgNum);
614  }
615  else if (ERR_BUFFER_EMPTY == passThruErr)
616  {
617  ; // User defined action
618  }
619  else
620  {
621  ; // User defined error handling
622  }
623  usleep(THREAD_DELAY);
624  }
625  }
626  else
627  {
628  ; // never used
629  }
630  return NULL;
631 }
632 /**************************************************************************************************/
Definition of structure with CAN Gateway's parameters.
Definition: cangw.cpp:32
static ErrCode_e canGwConnectChannels()
Function connects CAN Gateway's channels.
Definition: cangw.cpp:345
Baudrate 250 kbps.
Definition: cangw.hpp:48
Name of CAN Gateway's channel 2.
Definition: cangw.hpp:39
static ThreadParam_s threadParamCh1
Structure with thread parameters for Channel1.
Definition: cangw.cpp:85
static pthread_mutex_t gwMutex
Mutex for CAN Gateway's API.
Definition: cangw.cpp:89
ErrCode_e startPeriodic(Channel_e channel, J2534::PASSTHRU_MSG *txPassThruMsg, unsigned long interval)
Function starts CAN Gateway's periodic message.
Definition: cangw.cpp:263
unsigned long baudCh1
Baud rate of CAN CH1.
Definition: cangw.cpp:45
Baudrate 1 Mbps.
Definition: cangw.hpp:52
unsigned long baudCh2
Baud rate of CAN CH2.
Definition: cangw.cpp:47
unsigned long idDevice
ID of the device.
Definition: cangw.cpp:35
pthread_attr_t attr
Thread's attributes.
Definition: cangw.cpp:60
Name of CAN Gateway's channel 1.
Definition: cangw.hpp:37
Definition of structure with thread parameters.
Definition: cangw.cpp:55
static ErrCode_e canGwUninitRcvThread(Channel_e channel)
Function uninitializes receiving thread for given physical channel.
Definition: cangw.cpp:533
bool activeCh1
CAN CH1 active status.
Definition: cangw.cpp:49
unsigned long idCh1
ID of the CAN CH1.
Definition: cangw.cpp:37
Baudrate_e
Definition of CAN Gateway's baud rates.
Definition: cangw.hpp:43
static ErrCode_e canGwOpen()
Function opens CAN Gateway.
Definition: cangw.cpp:304
Header file for cangw.cpp.
ErrCode_e init(Baudrate_e baudChan1, Baudrate_e baudChan2, const RcvCb_t cbChan1, const RcvCb_t cbChan2)
Function initializes CAN Gateway device.
Definition: cangw.cpp:124
static GwParam_s gwParam
Structure with CAN device parameters.
Definition: cangw.cpp:83
static ErrCode_e canGwDisconnectChannels()
Function disconnects CAN Gateway's channels.
Definition: cangw.cpp:389
An error occurred.
Definition: cangw.hpp:30
static unsigned long TX_TIMEOUT
Timeout for PassThruWriteMsgs() function.
Definition: cangw.cpp:102
static ErrCode_e canGwInitRcvThread(Channel_e channel)
Function initializes receiving thread for given physical channel.
Definition: cangw.cpp:479
Channel_e
Definition of CAN Gateway channels' names.
Definition: cangw.hpp:34
unsigned long idFilterCh1
ID of the filter for CAN CH1.
Definition: cangw.cpp:41
static RcvCb_t rcvCbCh2
Receive callback function for Channel 2.
Definition: cangw.cpp:93
bool active
Thread's status.
Definition: cangw.cpp:62
No error.
Definition: cangw.hpp:28
static const unsigned long BAUD_VAL_125KBPS
Value for baud rate = 125 kbps.
Definition: cangw.cpp:104
ErrCode_e
Definition of CAN Gateway's error codes.
Definition: cangw.hpp:25
static J2534::PASSTHRU_MSG * rxPassThruMsgCh1
Pointer to receive buffer with PASSTHRU messages for Channel 1.
Definition: cangw.cpp:95
static ErrCode_e canGwClose()
Function closes CAN Gateway.
Definition: cangw.cpp:325
static RcvCb_t rcvCbCh1
Receive callback function for Channel 1.
Definition: cangw.cpp:91
Baudrate 125 kbps.
Definition: cangw.hpp:46
static ThreadParam_s threadParamCh2
Structure with thread parameters for Channel2.
Definition: cangw.cpp:87
Baudrate 500 kbps.
Definition: cangw.hpp:50
void(* RcvCb_t)(const J2534::PASSTHRU_MSG *rxPassThruMsg, unsigned long rxMsgNum)
Definition of callback function for receive frames.
Definition: cangw.hpp:56
unsigned long idFilterCh2
ID of the filter for CAN CH2.
Definition: cangw.cpp:43
static const unsigned long BAUD_VAL_500KBPS
Value for baud rate = 500 kbps.
Definition: cangw.cpp:108
static ErrCode_e canGwSetFilters()
Function sets CAN Gateway's message filters.
Definition: cangw.cpp:428
unsigned long idCh2
ID of the CAN CH2.
Definition: cangw.cpp:39
static J2534::PASSTHRU_MSG * rxPassThruMsgCh2
Pointer to receive buffer with PASSTHRU messages for Channel 2.
Definition: cangw.cpp:97
static const unsigned long BAUD_VAL_1MBPS
Value for baud rate = 1 Mbps.
Definition: cangw.cpp:110
bool activeCh2
CAN CH2 active status.
Definition: cangw.cpp:51
static const unsigned int MAX_RX_MSGS
Maximum number of messages to receive.
Definition: cangw.cpp:100
Channel_e gwChannel
CAN Gateway's channel handled by thread.
Definition: cangw.cpp:64
ErrCode_e send(Channel_e channel, J2534::PASSTHRU_MSG *txPassThruMsg)
Function sends PASSTHRU frame via given channel.
Definition: cangw.cpp:228
static const unsigned long BAUD_VAL_250KBPS
Value for baud rate = 250 kbps.
Definition: cangw.cpp:106
static void * canGwRcvThreadFunc(void *params)
Function handles CAN Gateway's receiving threads.
Definition: cangw.cpp:568
ErrCode_e uninit()
Function uninitializes CAN Gateway device.
Definition: cangw.cpp:201
pthread_t id
Thread's ID.
Definition: cangw.cpp:58